<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户容量总览</title>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <style type="text/css">
        .layui-table-cell {
            height: 100%;
            max-width: 100%;
        }
    </style>
</head>
<body>

<form class="layui-form">
    <div class="layui-inline">
        <div class="layui-input-inline">
            <input type="text" id="username" style="width: 330px" name="username" lay-verify="required" placeholder="请输入用户账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <button type="button" class="layui-btn" id="search">搜索</button>
</form>

<table id="userTable" lay-filter="userTable"></table>




<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">


    layui.use(['table','element'],function () {

        var table = layui.table;
        var element = layui.element;
        table.render({
            elem:'#userTable'
            ,url:'cloud-space/user'
            ,page:true
            ,limit:10
            ,limits:[6,10,15,20]
            ,cols:[[
                {field:'id',title:'编号',sort:true, width:80, align:'center'}
                ,{field:'username', title:'账号', align:'center'}
                ,{field:'name',title:'用户名', align:'center'}
                ,{field:'country',title:'云盘容量总览',align:'center',templet:function (d) {
                        return "<div class=\"layui-progress layui-progress-big\" lay-showPercent=\"true\">\n" +
                            "  <div class=\"layui-progress-bar layui-bg-blue\" lay-percent='"+ d.percent +"%'></div>\n" +
                            "</div>";
                    }, width: 800}
            ]]
            ,done:function (res,currentCount) {
                //table渲染完成后渲染element进度条
                element.render()
            }
        });


        /**
         * 搜索功能
         * */
        $("#search").click(function () {
            if($("#username").val() == ""){
                table.reload("userTable",{
                    url:'cloud-space/user',
                    page:{
                        curr:1
                    },
                    where:{
                        username:null,
                    }
                });
            }else{
                table.reload("userTable",{
                    url:'cloud-space/user',
                    where:{
                        username:$("#username").val(),
                    }
                });
            }
        });


    });
</script>

</body>
</html>